from rest_framework.response import Response
from rest_framework.views import APIView
from utils.LastAgent import get_insurance_agent
insurance_agent = get_insurance_agent()  # 放外面，仅创建一次
class InsuranceView(APIView):
    def post(self,request):
        name=request.POST.get('name')
        id_number=request.POST.get('idNumber')
        claim_amount=request.POST.get('amount')
        description=request.POST.get('description')
        result=insurance_agent.invoke(
            {"input":"以下是用户提供的信息，包括姓名、身份证号、理赔金额和理赔描述", #必须的input字段
            "user_input":
                  {"name": name, "id_number": id_number, "claim_amount": claim_amount, "description": description}})
        print("最终结果，",result["output"])
        return Response({"result": result["output"]})